package com.qdlc.p2p.biz.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.qdlc.p2p.biz.executer.AbstractExecuter;
import com.qdlc.p2p.biz.executer.ExecuterHelper;
import com.qdlc.p2p.biz.executer.impl.ActivityPlanExecuter;
import com.qdlc.p2p.biz.service.InviteService;
import com.qdlc.p2p.common.constant.Global;
import com.qdlc.p2p.common.enums.EnumActicityPlanNid;
import com.qdlc.p2p.common.util.DateUtil;
import com.qdlc.p2p.dal.dao.InviteDao;
import com.qdlc.p2p.dal.model.ActivityParamModel;
import com.qdlc.p2p.dal.model.UserInviteTenderTotal;

/**
 * 好友邀请奖励 业务处理实现
 *
 * @author zlhx
 * @version 2.0
 * @date 2015-04-23 16:01
 */
@Service(value = "inviteService")
public class InviteServiceImpl implements InviteService {

    @Resource
    private InviteDao inviteDao;

    @Override
    public List<UserInviteTenderTotal> friendYesterdayTenderStatistics() {
        return inviteDao.friendYesterdayTenderStatistics();
    }

    @Override
    public void inviteTenderAward(UserInviteTenderTotal tenderTotal) {
        ActivityParamModel param = new ActivityParamModel();
        param.setDate(DateUtil.getNow());
        param.setUserId(tenderTotal.getInviteUser());
        param.setMoney(tenderTotal.getTenderTotal());
        param.setBeInvitedUserId(tenderTotal.getUserId());
        param.setType(EnumActicityPlanNid.INVITE.getValue());
        Global.setTransfer("ap_param", param);
        AbstractExecuter activityPlanExecuter = ExecuterHelper.getExecuter(ActivityPlanExecuter.class);
        activityPlanExecuter.extend();
    }
}
